<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.11&key=9de88a718781910c9a1c81230827d1ce&plugin=AMap.TruckDriving,AMap.Autocomplete"></script>
        <title>货车路线</title>
        <style>
            body{
                width: 100%;
                height: 100%;
            }
            *{
                padding: 0;
                margin: 0;
            }
            #container{
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
            }
            #panel{
                position: fixed;
                background: white;
                top: 10px;
                right: 10px;
                width: 280px;
            }
            #search{
                width: 200px;
                height: 160px;
                position: absolute;
                left: 10px;
                top: 10px;
                background: white;
            }
        </style>
    </head>
    <body>
        <div id="container"></div>
        <div id="panel"></div>
        <div id="search">
            城市：<input type="text" name=""  id="cityName"/><br />
            起点：<input type="text" name=""  id="startNode"/><br />
            <!--途径：<input type="text" name="" id="centerNode"/><br />-->
            终点：<input type="text" name="" id="endNode"/><br />
            <button id="btn">规划路线</button>
        </div>
        
        <script>
            var map = new AMap.Map('container',{
                zoom:11,
                center:[116.379391,39.861536],
                
            });
            
            new AMap.Autocomplete({
                input:'cityName'
            });
            new AMap.Autocomplete({
                input:'startNode'
            });
            // new AMap.Autocomplete({
            //     input:'centerNode'
            // });
            new AMap.Autocomplete({
                input:'endNode'
            });
            
            btn.onclick = function(){
                new AMap.TruckDriving({
                    map:map,
                    panel:'panel',
                    size:1,
                    city:'beijing'
                }).search([
                    {keyword:startNode.value,city:cityName},
                    {keyword:startNode.value,city:cityName},
                    {keyword:endNode.value,city:cityName}
                ],function(status,data){
                    console.log(data);
                });
            }
            
            
            
        </script>
    </body>
</html>